package cn.itsource.pethome.system.dictionary.service.impl;

import cn.itsource.pethome.base.service.impl.IBaseServiceImpl;
import cn.itsource.pethome.system.dictionary.domain.Systemdictionarydetail;
import cn.itsource.pethome.system.dictionary.domain.Systemdictionarytype;
import cn.itsource.pethome.system.dictionary.mapper.SystemdictionarydetailMapper;
import cn.itsource.pethome.system.dictionary.mapper.SystemdictionarytypeMapper;
import cn.itsource.pethome.system.dictionary.service.ISystemdictionarytypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ISystemdictionarytypeServiceImpl extends IBaseServiceImpl<Systemdictionarytype> implements ISystemdictionarytypeService {
    @Autowired
    private SystemdictionarytypeMapper mapper;
    @Autowired
    private SystemdictionarydetailMapper systemdictionarydetailMapper;
    @Override
    public void delete(Long id) {
        List<Systemdictionarydetail> list = systemdictionarydetailMapper.findbytpID(id);
        if (list.size()==0){
            mapper.delete(id);
        }else {
            throw  new RuntimeException("字典明细有数据不能删除");
        }
    }
}
